package com.iecg.controller.monitor;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.iecg.api.entity.IecgDeviceManage;
import com.iecg.service.IecgDeviceManageService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("monitor/equip" )
@Api(value = "monitor_equip", tags = "Monitor设备管理")
public class MonitorEquipManagerController {

	private final IecgDeviceManageService deviceManageService;
	/**
	 * 新增设备管理
	 * @param
	 * @return
	 */
	@ApiOperation(value = "新增设备", notes = "新增设备")
	@SysLog("新增设备" )
	@PostMapping
	public R save(@RequestBody IecgDeviceManage deviceManager) {
		deviceManager.setUserId(-1L);
		return R.ok(deviceManageService.save(deviceManager));
	}

	@ApiOperation(value = "设备列表", notes = "设备列表")
	@SysLog("设备列表" )
	@GetMapping
	public R get() {
		return R.ok(deviceManageService.list(Wrappers.<IecgDeviceManage>query()
				.lambda().eq(IecgDeviceManage::getUserId, -1)));
	}

}
